package com.own.component.elastic.exception;

import com.own.component.common.model.ExceptionMessageModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * ElasticExceptionHandler
 *
 * @author chenxueli
 * @date 2021-8-27 14:30:35
 */
@Slf4j
@Order(1)
@RestControllerAdvice
public class ElasticExceptionHandler {

    /**
     * 处理 ElasticException 异常 （缓存异常）
     *
     * @param e 异常信息
     * @return 返回信息
     */
    @ExceptionHandler(ElasticException.class)
    public ExceptionMessageModel handleElasticException(ElasticException e) {
        log.error(e.getMessage(), e);
        return new ExceptionMessageModel(e);
    }

}
